function好難


Q1: 請問以下會輸出什麼內容?

let x = y(function z() {
 console.log('I am z') 
})
function y(fn) {
  fn()
  console.log('I am y')
  return fn
}
x()
console.log(y)  
console.log(x)  
console.log(x === y)
answer
I am z
I am y
I am z
[Function: y]
[Function: z]
false

參考文章覺得 JavaScript function 很有趣的我是不是很奇怪








你可能感興趣的文章

Find the nth smallest value

Find the nth smallest value

[第六週]  CSS  Part4 - Position 定位

[第六週] CSS Part4 - Position 定位

[自我] 理財規劃

[自我] 理財規劃






留言討論